package com.zretc.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zretc.dao.PaySalaryMapper;
import com.zretc.entity.PaySalary;
import com.zretc.service.PaySalaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class PaySalaryServiceImpl implements PaySalaryService {

    @Autowired
    private PaySalaryMapper paySalaryMapper;
    @Override
    public PageInfo<PaySalary> findBy(Map<String, Object> map) {

        Integer page = (Integer) map.get("page");
        Integer size = (Integer) map.get("size");
        String name = (String) map.get("name");

        if (name =="" ||name==null){
            map.put("name",null);
        }else {
            map.put("name","%"+name+"%");
        }
        PageHelper.startPage(page,size);

        List<PaySalary> by = paySalaryMapper.findBy(map);
        PageInfo<PaySalary> pageInfo=PageInfo.of(by);
        return pageInfo;
    }
}
